package com.yingdong.startup;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileLock;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DeamonProcess {
	static Log logger = LogFactory.getLog(DeamonProcess.class);

	public static void main(String[] args) throws IOException, InterruptedException {

		File file = new File("deamon.lock");
		if (!file.exists()) {
			file.createNewFile();
		}
		FileOutputStream outputStream = new FileOutputStream(file);

		FileLock fileLock = outputStream.getChannel().tryLock();
		if (fileLock == null) {
			logger.info("有程序正在运行，不能重复开启");
		}
		Thread.sleep(Long.MAX_VALUE);

	}
}
